package com.grammer;

import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;


@Repeatable(Hobbies.class)
@Retention(RetentionPolicy.RUNTIME)
@interface Hobby {

  String value();
}

@Retention(RetentionPolicy.RUNTIME)
@interface Hobbies {

  Hobby[] value();
}

@Hobby("swimming")
@Hobby("singing")
@Hobby("dancing")
public class RepeatableDemo {

  public static void main(String[] args) {
    Class cls = RepeatableDemo.class;
    Hobby[] hobbies = (Hobby[]) cls .getAnnotationsByType(Hobby.class);
    for (int i = 0; i < hobbies.length; i++) {
      System.out.println(hobbies[i].value());
    }
  }
}







